﻿Ext.define('yzmh.view.CheckCode', {
    extend: 'Ext.form.field.Text',
    alias: 'widget.checkcode',
    inputType: 'codefield',
    codeUrl: Ext.BLANK_IMAGE_URL,
    isLoader: true,
    onRender: function (ct, position) {
        this.callParent(arguments);
        if (this.up("toolbar") != null) {
            ct = this.labelEl.parent();
            ct.setHTML("");
        }
        this.codeEl = ct.createChild({ tag: 'img', src: Ext.BLANK_IMAGE_URL });
        this.codeEl.addCls('x-form-code');
        this.codeEl.on('click', this.loadCodeImg, this);

        if (this.isLoader) this.loadCodeImg();
    },
    alignErrorIcon: function () {
        this.errorIcon.alignTo(this.codeEl, 'tl-tr', [2, 0]);
    },
    loadCodeImg: function () {
        this.codeEl.set({ src: this.codeUrl + '?NumCount=4&id=' + Math.random() });
    }
})